﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Configuration;
using System.Configuration;

namespace YasharEl.Infrastructure.ServiceModel.Hosting.SelfHosting
{
    public class AutoSelfHostingBehaviorExtensionElement : BehaviorExtensionElement
    {
        public const string ENABLE_SELF_HOSTING_ATTRIBUTE_NAME = "enableSelfHosting";

        [ConfigurationProperty(ENABLE_SELF_HOSTING_ATTRIBUTE_NAME, IsRequired = false)]
        public bool EnableSelfHosting
        {
            get
            {
                return (bool)base[ENABLE_SELF_HOSTING_ATTRIBUTE_NAME];
            }
            set
            {
                base[ENABLE_SELF_HOSTING_ATTRIBUTE_NAME] = value;
            }
        }

        public override Type BehaviorType
        {
            get { return typeof(AutoSelfHostingBehavior); }
        }

        protected override object CreateBehavior()
        {
            return new AutoSelfHostingBehavior(EnableSelfHosting);
        }
    }
}
